/**
* 后台管理左边菜单
*/ 
<template>
  <div class="menulist">
    <el-menu v-if="user.role==1" :collapse="collapsed" collapse-transition router :default-active="$route.path" unique-opened class="el-menu-vertical-demo" background-color="#334157" text-color="#fff" active-text-color="#ffd04b">
      <div class="logobox">
        <div>社区智慧助老服务平台</div>
        <!-- <img class="logoimg" src="@/assets/img/logo.png" alt=""> -->
      </div>
      <el-submenu v-for="menu in adminMenu.adminMenus" :key="menu.menuid" :index="menu.menuname">
        <template slot="title">
          <font-awesome-icon :icon="['fas', menu.icon]"></font-awesome-icon>
          <span>{{menu.menuname}}</span>
        </template>
        <el-menu-item-group>
          <el-menu-item v-for="chmenu in menu.menus" :index="'/'+chmenu.url" :key="chmenu.menuid">
            <font-awesome-icon :icon="['fas', chmenu.icon]"></font-awesome-icon>
            <span>{{chmenu.menuname}}</span>
          </el-menu-item>
        </el-menu-item-group>
      </el-submenu>
    </el-menu>
    <el-menu v-if="user.role==2" :collapse="collapsed" collapse-transition router :default-active="$route.path" unique-opened class="el-menu-vertical-demo" background-color="#334157" text-color="#fff" active-text-color="#ffd04b">
      <div class="logobox">
        <div>社区智慧助老服务平台</div>
        <!-- <img class="logoimg" src="@/assets/img/logo.png" alt=""> -->
      </div>
      <el-menu-item :index="'/admin/merchant/dashboard'">
        <font-awesome-icon :icon="['fas', 'tachometer-alt']"></font-awesome-icon>
        <span>首页</span>
      </el-menu-item>
      <el-submenu v-for="menu in adminMenu.managerMenus" :key="menu.menuid" :index="menu.menuname">
        <template slot="title">
          <font-awesome-icon :icon="['fas', menu.icon]"></font-awesome-icon>
          <span>{{menu.menuname}}</span>
        </template>
        <el-menu-item-group>
          <el-menu-item v-for="chmenu in menu.menus" :index="'/'+chmenu.url" :key="chmenu.menuid">
            <font-awesome-icon :icon="['fas', chmenu.icon]"></font-awesome-icon>
            <span>{{chmenu.menuname}}</span>
          </el-menu-item>
        </el-menu-item-group>
      </el-submenu>
    </el-menu>
  </div>
</template>
<script>

export default {
  name: 'leftnav',
  data() {
    return {
      collapsed: false,
      adminMenu: [],
      user: {}
    }
  },
  // 创建完毕状态(里面是操作)
  created() {
    this.user = JSON.parse(localStorage.getItem('LoginAdmin'))
    console.log('登录的管理员：',this.user)
    // if(this.user==null){
    //   this.user = {userRole:1, realName: '开发模式'}
    // }
    // if(this.user.role==2){
    //   this.userRole = '管理员'
    // }
    this.adminMenu = {
      success: true,
      adminMenus: [
        {
          menuid: 1,
          icon: 'users',
          menuname: '用户管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 11,
              icon: 'user',
              menuname: '社区老人管理',
              hasThird: 'N',
              url: 'admin/usermgr',
              menus: null
            },{
              menuid: 12,
              icon: 'vcard',
              menuname: '志愿者管理',
              hasThird: 'N',
              url: 'admin/volmgr',
              menus: null
            }, {
              menuid: 13,
              icon: 'id-card-alt',
              menuname: '社区管理员管理',
              hasThird: 'N',
              url: 'admin/manager/user',
              menus: null
            }
          ]
        },
        {
          menuid: 2,
          icon: 'building',
          menuname: '社区管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 12,
              icon: 'list',
              menuname: '社区列表',
              hasThird: 'N',
              url: 'admin/community/list',
              menus: null
            }
          ]
        },{
          menuid: 3,
          icon: 'comments',
          menuname: '论坛管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 32,
              icon: 'comment',
              menuname: '帖子列表',
              hasThird: 'N',
              url: 'admin/forum/list',
              menus: null
            }
          ]
        },
        {
          menuid: 4,
          icon: 'file',
          menuname: '日志管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 41,
              icon: 'bookmark',
              menuname: '服务请求日志',
              hasThird: 'N',
              url: 'admin/log/service/list',
              menus: null
            },{
              menuid: 42,
              icon: 'history',
              menuname: '用户登录日志',
              hasThird: 'N',
              url: 'admin/log/list',
              menus: null
            }
          ]
        },
        {
          menuid: 7,
          icon: 'cogs',
          menuname: '系统管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 71,
              icon: 'info-circle',
              menuname: '个人信息',
              hasThird: 'N',
              url: 'admin/profile',
              menus: null
            },{
            menuid: 72,
            icon: 'gear',
            menuname: '系统参数',
            hasThird: 'N',
            url: 'admin/config/list',
            menus: null
          }
          ]
        }
      ],
      // 社区管理员菜单
      managerMenus: [
        {
          menuid: 1,
          icon: 'heart',
          menuname: '助老服务管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 11,
              icon: 'clipboard-list',
              menuname: '服务记录',
              hasThird: 'N',
              url: 'admin/service/list',
              menus: null
            }
            // ,{
            //   menuid: 12,
            //   icon: 'feed',
            //   menuname: '用户反馈',
            //   hasThird: 'N',
            //   url: 'admin/orders',
            //   menus: null
            // }
          ]
        },
        {
          menuid: 2,
          icon: 'file-text',
          menuname: '资讯管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 51,
              icon: 'list',
              menuname: '资讯列表',
              hasThird: 'N',
              url: 'admin/info/list',
              menus: null
            }
          ]
        },
        {
          menuid: 3,
          icon: 'comments',
          menuname: '论坛管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 52,
              icon: 'comment',
              menuname: '帖子列表',
              hasThird: 'N',
              url: 'admin/mer/forum/list',
              menus: null
            }
          ]
        },
        {
          menuid: 71,
          icon: 'cogs',
          menuname: '个人中心',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 73,
              icon: 'info-circle',
              menuname: '个人信息',
              hasThird: 'N',
              url: 'admin/merchant/profile',
              menus: null
            }
          ]
        }
      ],
      msg: 'success'
    }
    
  }
}
</script>
<style>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 240px;
  min-height: 400px;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  border: none;
  text-align: left;
}
.el-menu-item-group__title {
  padding: 0px;
}
.el-menu-bg {
  background-color: #1f2d3d !important;
}
.el-menu {
  border: none;
}
.logobox {
  height: 40px;
  line-height: 40px;
  color: #fff;
  font-size: 18px;
  text-align: center;
  padding: 10px 0px;
}
.logoimg {
  height: 40px;
}
</style>